import java.util.Arrays;
import java.util.Random;
/**
* A class with three static methods that all return the number of foursums for a list with
* no duplicates. 
*/

public class MiningNobel
{
	//An algorithm which finds all foursums in quartic time
	public static int quartic(double[] ds)
	{
		int N = ds.length;//Amount of elements in the set
		int count = 0;//The number of foursums
		
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++)
				for (int k = 0; k < N; k++)
					for (int l = 0; l < N; l++)
						if (ds[i] + ds[j] + ds[k] + ds[l] == 0)
							count++;
		return count;
	}
	
	//A method finding all foursums in n^3*log(n) time
	public static int cubic(double[] ds)
	{
		int N = ds.length;//Amount of elements in the set
		int count = 0;//The number of foursums
		
		// Sort array in ascending order
		Arrays.sort(ds);
		
		int x = 0;
		int y = 0;
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++)
				for (int k = 0; k < N; k++)
				{	
					int l = 0;
					
					// Find element that satisfies condition if any exists
					if(ds[i] + ds[j] + ds[k] == 0)
						l = Arrays.binarySearch(ds, 0);
					else
						l = Arrays.binarySearch(ds, -(ds[i] + ds[j] + ds[k]));
					
					//If l>=0 an element matching the criteria was found
					if (l >= 0)
					{
						count++;
					}
				}
		return count;
	}
	
	//A method which finds the number of foursums in a set in n^2*log(n) time
	public static int quadratic(double[] ds)
	{
		int N = ds.length;//Amount of elements in the set
		int count = 0;//The number of foursums
		double[] newds = new double[N*N];//An array which shall contain the sum of 
										//all pairs in the original array
		
		//Adding the sums to the list
		for (int i = 0; i < N; i++)
			for (int j = 0; j < N; j++)
				newds[N*i + j] = ds[i] + ds[j];
		
		//Sorting sums ascending
		Arrays.sort(newds);
		
		for (int i = 0; i < N*N; i++)
		{
			
			int k =0;
			//Apparently 0 and -0 is not the same in java
			if(newds[i]==0.0)
				k = Arrays.binarySearch(newds, 0);
			else
				k = Arrays.binarySearch(newds, -newds[i]);
			
			//If k>=0 an element matching the criteria
			if (k >= 0)
			{
				double a = 1.907348633e-06;
				//Figure out if more than one element matches the criteria
				//By looking at where the found element + and - 2^-19 would be placed in the list
				int top = Math.abs(Arrays.binarySearch(newds, newds[k] + a)) -1;
				int bot = Math.abs(Arrays.binarySearch(newds, newds[k] - a)) -1;
				if (top >= N*N) top--;
				while(newds[top] > newds[k]) top--;
				while(newds[bot] < newds[k]) bot++;
				count += top - bot + 1;
				
			}
		}
		return count;
	}
	//Main class reading the input file and timing the quadratic method for finding foursums.
	public static void main(String[] args)
	{
		Random rand = new Random();
		
		int N = StdIn.readInt();
		double[] ds = new double[N];
		StdIn.readLine();
		
		for (int i = 0; i < N; i++)
		{
			ds[i] = Double.parseDouble(StdIn.readLine().split(",")[1]);
		}
		
		Stopwatch sw = new Stopwatch();
		StdOut.println("Quadratic: " + quadratic(ds));
		StdOut.println(sw.elapsedTime());
		//StdOut.println("Cubic: " + cubic(ds));
		//StdOut.println("Quartic: " + quartic(ds));
		
	}
}